/*
 * @Description: 项目管理 - 接口
 * @Author: DSY
 * @Date: 2022-03-14 21:44:47
 * @LastEditors: DHL
 * @LastEditTime: 2022-07-18 16:41:13
 */

import { $get, $post, $put } from '/@/utils/http'
import { ContentTypeEnum } from '/@/constant/http'
import {
  ProjectListResultModel,
  ProjectModel,
  ProjectPageParams,
  ProjectPageResultModel,
  ProjectResultModel
} from './model/projectModel'

/**
 * 分页查询
 */
export const apiProjectSearch = (searchParams: ProjectPageParams) =>
  $get<ProjectPageResultModel>({
    url: '/sys/twbProject/search',
    params: searchParams
  })

/**
 * 根据ID获取详情
 */
export const apiProjectGetById = (id: string) =>
  $get<ProjectResultModel>({
    url: '/sys/twbProject/getById',
    params: { id: id }
  })

/**
 * 保存信息
 */
export const apiProjectSave = (saveParams: ProjectModel) =>
  $post<ProjectResultModel>({
    url: '/sys/twbProject/save',
    contentType: ContentTypeEnum.json,
    params: saveParams
  })

/**
 * 更新信息
 */
export const apiProjectUpdateById = (updateParams: ProjectModel) =>
  $put<ProjectResultModel>({
    url: '/sys/twbProject/updateById',
    contentType: ContentTypeEnum.json,
    params: updateParams
  })

/**
 * 根据ID删除信息
 */
export const apiProjectDeleteById = (id: string) =>
  $post<ProjectResultModel>({
    url: '/sys/twbProject/delete',
    params: { id: id }
  })

/**
 * 批量删除信息
 */
export const apiProjectBatchDeleteByIds = (ids: string) =>
  $post<ProjectResultModel>({
    url: '/sys/twbProject/batchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 根据ID逻辑删除信息
 */
export const apiProjectLogicDeleteById = (id: string) =>
  $post<ProjectResultModel>({
    url: '/sys/twbProject/logicDeleteById',
    params: { id: id }
  })

/**
 * 批量逻辑删除
 */
export const apiProjectLogicBatchDeleteByIds = (ids: string) =>
  $post<ProjectResultModel>({
    url: '/sys/twbProject/logicBatchDeleteByIds',
    params: { ids: ids }
  })

/**
 * 查询项目列表
 * @param searchParams
 * @returns
 */
export const apiProjectList = (searchParams: any) =>
  $get<ProjectListResultModel>({
    url: '/sys/twbProject/list',
    params: searchParams
  })

/**
 * 根据appIds查询项目信息
 * @param appIds
 * @returns
 */
export const apiProjectByAppIds = (appIds: string) =>
  $get<ProjectListResultModel>({
    url: '/sys/twbProject/projectsByAppIds',
    params: { appIds: appIds }
  })
